<%--
  Created by IntelliJ IDEA.
  User: ZTencent
  Date: 2022/12/29
  Time: 17:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fm" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${pageContext.request.contextPath}/statics/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/css/style.css"/>
    <link href="${pageContext.request.contextPath}/statics/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace.min.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/font/css/font-awesome.min.css" />
    <!--[if lte IE 8]>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/statics/assets/css/ace-ie.min.css" />
    <![endif]-->
    <script src="${pageContext.request.contextPath}/statics/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/typeahead-bs2.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/statics/assets/layer/layer.js" type="text/javascript" ></script>
    <script src="${pageContext.request.contextPath}/statics/assets/laydate/laydate.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/statics/js/lrtk.js" type="text/javascript" ></script>
    <title>订单处理</title>
</head>

<body>
<div class="clearfix">
    <!-- <div class="handling_style" id="order_hand">
          <div id="scrollsidebar" class="left_Treeview">
            <div class="show_btn" id="rightArrow"><span></span></div>
            <div class="widget-box side_content" >
             <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
             <div class="side_list"><div class="widget-header header-color-green2"><h4 class="lighter smaller">订单操作</h4></div>
             <div class="widget-body">
              <ul class="b_P_Sort_list">
                 <li><i class="orange  fa fa-reorder"></i><a href="#">全部订单(235)</a></li>
                 <li><i class="fa fa-sticky-note pink "></i> <a href="#">已完成(235)</a></li>
                 <li><i class="fa fa-sticky-note pink "></i> <a href="#">代付款(15)</a> </li>
                 <li><i class="fa fa-sticky-note pink "></i> <a href="#">代发货(56)</a></li>
                 <li><i class="fa fa-sticky-note pink "></i> <a href="#">代收货(32)</a></li>
                </ul>
            </div>
           </div>
          </div>
         </div> -->
    <div class="order_list_style" id="order_list_style" style="margin-left: 20px;">
        <div class="search_style" style="margin: 10px 0px;">
            <form action="${pageContext.request.contextPath}/business/order/query" method="get">
            <ul class="search_content clearfix">
                <input type="hidden" name="list" value="${list}"/>
                <li><label class="l_f">订单编号</label><input name="no" type="text"  id="no" class="text_add" placeholder="输入订单编号"  style=" width:250px"/></li>
                <!--<li><label class="l_f">交易时间</label><input  class="inline laydate-icon" id="start" style=" margin-left:10px;"></li>-->
                <li style="width:90px;"><button type="submit" id="query" class="btn_search"><i class="fa fa-search"></i>查询</button></li>
            </ul>
            </form>
        </div>
        <!--交易订单列表-->
        <div class="Orderform_list">
            <table class="table table-striped table-bordered table-hover" id="sample-table">
                <thead>
                <tr>
                    <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th>
                    <th width="120px">订单编号</th>
                    <th width="100px">订单金额</th>
                    <th width="100px">交易时间</th>
                    <th width="180px">优惠卷</th>
                    <th width="80px">实付金额</th>
                    <th width="100px">优惠金额</th>
                    <th width="70px">状态</th>
                    <th width="300px">操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="o" items="${pageinfo.list}">
                <tr>
                    <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                    <td>${o.outTradeNo}</td>
                    <td class="order_product_name">
                            ${o.totalAmount}
                    </td>
                    <td><fmt:formatDate value="${o.placeOrderTime}" pattern="yyyy-MM-dd"/> </td>

                    <td> ${o.useCoupon}</td>
                    <td>${o.payPrice}</td>
                    <td>${o.couponPrice}</td>
                    <td class="td-status"><span class="label label-success radius">
                        <c:choose>
                            <c:when test="${o.orderType==1}">
                                未支付
                            </c:when>
                            <c:when test="${o.orderType==2}">
                                已支付
                            </c:when>
                            <c:when test="${o.orderType==3}">
                                已发货
                            </c:when>
                            <c:when test="${o.orderType==4}">
                                骑手接单
                            </c:when>
                            <c:when test="${o.orderType==5}">
                                已完成
                            </c:when>
                            <c:when test="${o.orderType==6}">
                                已取消
                            </c:when>
                        </c:choose>
                    </span></td>
                    <td>
                        <button id="deliver" onclick="deliver(${o.orderType},'${o.outTradeNo}',${list})" title="发货"  class="btn btn-xs btn-success"><i class="fa fa-cubes bigger-120"></i></button>

                        <a title="订单详细"  href="${pageContext.request.contextPath}/business/order/detail?outTradeNo=${o.outTradeNo}"  class="btn btn-xs btn-info order_detailed" ><i class="fa fa-list bigger-120"></i></a>
                        <button title="取消订单" onclick="cancel(${o.orderType},'${o.outTradeNo}',${list})"  class="btn btn-xs btn-danger">★</button>
                        <a title="删除" href="javascript:;"  onclick="del(this,${o.orderType},'${o.outTradeNo}',${list})" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>
                    </td>
                </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>
    </div>
</div>
</div>
<script>
    function deliver(type,order,list) {
        if(type==2){
            var isok = confirm("确认要发货吗？");
            if (isok){
                $.getJSON("${pageContext.request.contextPath}/business/order/deliver",{"no":order},function (e) {
                    if (e.code==200){
                        alert(e.message);
                        if(list==0){
                            window.location.href="${pageContext.request.contextPath}/business/order/list?pageindex=1"
                        }else{
                            window.location.href="${pageContext.request.contextPath}/business/order/waitList?pageindex=1"
                        }
                    }else {
                        alert(e.message)
                        // console.log(e)
                    }
                })
            }
        }else{
            alert("该订单已发货")
        }

    }

    function cancel(type,order,list) {
        if(type==2){
            var isok = confirm("确认要取消吗？");
            if (isok){
                $.getJSON("${pageContext.request.contextPath}/business/order/cancel",{"no":order},function (e) {
                    if (e.code==200){
                        alert(e.message);
                        if(list==0){
                            window.location.href="${pageContext.request.contextPath}/business/order/list?pageindex=1"
                        }else{
                            window.location.href="${pageContext.request.contextPath}/business/order/cancelList?pageindex=1"
                        }
                    }else {
                        alert(e.message)
                        // console.log(e)
                    }
                })
            }
        }else{
            alert("该订单无法取消")
        }
    }

    function del(target,type,order,list) {
        if(type==5||type==6){
            var isok = confirm("确认要删除吗？");
            if (isok){
                $.getJSON("${pageContext.request.contextPath}/business/order/del",{"no":order},function (e) {
                    if (e.code==200){
                        alert(e.message);
                        /*删除dom元素*/
                        $(target).parent().parent().remove();
                    }else {
                        alert(e.message)
                        // console.log(e)
                    }
                })
            }
        }else {
            alert("该订单无法删除")
        }

    }

</script>
</body>
</html>


